feat: cohort CSV sync endpoint and cohort summary on segments - #8294
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
2 Skipped Deployments
|
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughAdds multipart CSV synchronisation for cohorts. The change validates CSV size and content, extracts identifiers, updates memberships in batches, tracks ignored rows, increments cohort versions, and queues delta application. Cohort creation now accepts and persists metadata. Segment responses expose related cohort details. The change adds metrics, event catalogue entries, tests, and OpenAPI schemas. Estimated code review effort: 4 (Complex) | ~60 minutes Merge Risk: 🟠 High · up to The CSV synchronization feature can strand membership updates, accept identifiers that downstream processing cannot handle, or leave external membership state inconsistent with the database under concurrent sync and application. These correctness and data-integrity risks make the PR unsafe to merge until the synchronization and validation paths are fixed. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Docker builds report
|
|
@themis-blindfold review |
✅ private-cloud · depot-ubuntu-latest-16 — run #19704 (attempt 1)Playwright Test Results (private-cloud - depot-ubuntu-latest-16)Details
🗂️ Previous results✅ private-cloud · depot-ubuntu-latest-arm-16 — run #19704 (attempt 1)Playwright Test Results (private-cloud - depot-ubuntu-latest-arm-16)Details
✅ oss · depot-ubuntu-latest-arm-16 — run #19704 (attempt 1)Playwright Test Results (oss - depot-ubuntu-latest-arm-16)Details
✅ oss · depot-ubuntu-latest-16 — run #19704 (attempt 1)Playwright Test Results (oss - depot-ubuntu-latest-16)Details
✅ private-cloud · depot-ubuntu-latest-arm-16 — run #19700 (attempt 1)Playwright Test Results (private-cloud - depot-ubuntu-latest-arm-16)Details
✅ private-cloud · depot-ubuntu-latest-16 — run #19700 (attempt 1)Playwright Test Results (private-cloud - depot-ubuntu-latest-16)Details
✅ oss · depot-ubuntu-latest-arm-16 — run #19702 (attempt 1)Playwright Test Results (oss - depot-ubuntu-latest-arm-16)Details
✅ oss · depot-ubuntu-latest-arm-16 — run #19700 (attempt 1)Playwright Test Results (oss - depot-ubuntu-latest-arm-16)Details
✅ oss · depot-ubuntu-latest-16 — run #19702 (attempt 1)Playwright Test Results (oss - depot-ubuntu-latest-16)Details
✅ oss · depot-ubuntu-latest-16 — run #19700 (attempt 1)Playwright Test Results (oss - depot-ubuntu-latest-16)Details
✅ private-cloud · depot-ubuntu-latest-arm-16 — run #19370 (attempt 1)Playwright Test Results (private-cloud - depot-ubuntu-latest-arm-16)Details
✅ private-cloud · depot-ubuntu-latest-16 — run #19370 (attempt 1)Playwright Test Results (private-cloud - depot-ubuntu-latest-16)Details
|
Visual Regression19 screenshots compared. See report for details. |
There was a problem hiding this comment.
Actionable comments posted: 5
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 6fc61ada-1f5d-43a2-8a9d-94781de30573
📒 Files selected for processing (17)
api/cohorts/constants.pyapi/cohorts/dataclasses.pyapi/cohorts/exceptions.pyapi/cohorts/metrics.pyapi/cohorts/serializers.pyapi/cohorts/services.pyapi/cohorts/views.pyapi/segments/serializers.pyapi/segments/views.pyapi/tests/unit/cohorts/conftest.pyapi/tests/unit/cohorts/test_services.pyapi/tests/unit/cohorts/test_views.pyapi/tests/unit/segments/test_unit_segments_views.pydocs/docs/deployment-self-hosting/observability/_events-catalogue.mddocs/docs/deployment-self-hosting/observability/_metrics-catalogue.mdmcp/src/flagsmith_mcp/openapi.jsonopenapi.yaml
⚖️ Themis review: ✅ Ship itClean, well-structured addition of the CSV sync endpoint and cohort summary on segments. The delta computation in
📝 Walkthrough
🧪 How to verify
Product take: This closes the loop on CSV-based cohort management by giving the dashboard everything it needs to upload, re-sync, and display cohort membership. Solid capability addition that unlocks the full create-from-CSV workflow. 🧭 Assumptions & unverified claims
A CSV walks into a bar; the parser orders one identifier, neat — no duplicates, no empties, hold the BOM. · reviewed at aa61a35 |
05b2fcf to
033c67d
Compare
aa61a35 to
4083994
Compare
71a387d to
3a5f36a
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## feat/create-segment-from-csv #8294 +/- ##
===============================================================
Coverage ? 98.76%
===============================================================
Files ? 1586
Lines ? 63514
Branches ? 0
===============================================================
Hits ? 62730
Misses ? 784
Partials ? 0 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
232f6a7 to
9fbfb13
Compare
9fbfb13 to
27adf8f
Compare
74e5d3c to
f1948e1
Compare
Thanks for submitting a PR! Please check the boxes below:
docs/if required so people know about the feature.Changes
Adds the API surface the dashboard needs to create segments from a CSV of identifiers, on top of the cohort CRUD from #8248.
CSV sync endpoint
POST /api/v1/environments/{api_key}/cohorts/{id}/sync-csv/: multipart upload withfile,identifier_column(0-based, defaults to the first column) andhas_header(defaults to true).202with{version, added, removed, unchanged, ignored: {empty, duplicates, too_long}}and queues the membership delta application inside the transaction, with a row lock on the cohort and a version bump.413.Cohort creation
POST .../cohorts/now accepts segment metadata (custom fields), applied to the managed segment.Segments API
cohortsummary (id,environment,source_type,version,deletion_requested_at), prefetched on the list view. This lets the dashboard tag CSV segments, route their deletion through the cohorts endpoint, and grey out segments awaiting drain.Observability
flagsmith_cohorts_csv_syncs_totalandflagsmith_cohorts_csv_sync_identifiers, newcohorts.csv.syncedevent, both documented in the observability catalogues.How did you test this code?